﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;

using MaxStudio.Concrete.DBUtility;

namespace MaxStudio.Concrete.Server.Dao
{
    public partial class ConcreteDaoDataContext : System.Data.Linq.DataContext
    {
        #region RPTPhysicalPropertiesOfementTest

        public List<tb_RPT_PhysicalPropertiesOfementTest> GetAllPhysicalPropertiesOfementTest()
        {
            var query = (from obj in this.tb_RPT_PhysicalPropertiesOfementTests
                         where obj.IsDelete == 0
                         select obj).ToList();
            return query;
        }

        public List<tb_RPT_PhysicalPropertiesOfementTest> GetPhysicalPropertiesOfementTestByContition(string strSamplingDate, string strTestDate,
                                                                               string strTestNumbers, string strCementManufacturer, 
                                                                                string strBatchNumber, string strStrengthGrade, string strTest,
                                                                                string strCalculation, string strApproval)
        {
            var tq = from obj in this.tb_RPT_PhysicalPropertiesOfementTests
                     where obj.IsDelete == 0
                     select obj;

            if (strSamplingDate.Length > 0)
            {
                tq = tq.Where(entity => entity.SamplingDate == strSamplingDate);
            }

            if (strTestDate.Length > 0)
            {
                tq = tq.Where(entity => entity.TestDate == strTestDate);
            }

            if (strTestNumbers.Length > 0)
            {
                tq = tq.Where(entity => entity.TestNumbers == strTestNumbers);
            }

            if (strCementManufacturer.Length > 0)
            {
                tq = tq.Where(entity => entity.CementManufacturer == strCementManufacturer);
            }
            if (strBatchNumber.Length > 0)
            {
                tq = tq.Where(entity => entity.BatchNumber == strBatchNumber);
            }
            if (strStrengthGrade.Length > 0)
            {
                tq = tq.Where(entity => entity.StrengthGrade == strStrengthGrade);
            }
            if (strTest.Length > 0)
            {
                tq = tq.Where(entity => entity.Test == strTest);
            }
            if (strCalculation.Length > 0)
            {
                tq = tq.Where(entity => entity.Calculation == strCalculation);
            }
            if (strApproval.Length > 0)
            {
                tq = tq.Where(entity => entity.Approval == strApproval);
            }

            var query = tq.ToList();
            return query;
        }

        public tb_RPT_PhysicalPropertiesOfementTest GetPhysicalPropertiesOfementTestById(int id)
        {
            return this.tb_RPT_PhysicalPropertiesOfementTests.SingleOrDefault(tb_RPT_PhysicalPropertiesOfementTests => tb_RPT_PhysicalPropertiesOfementTests.Id == id);
        }

        public void CreatePhysicalPropertiesOfementTest(tb_RPT_PhysicalPropertiesOfementTest entity)
        {
            entity.CreateDate = DateTime.Now;
            entity.CreateBy = 1;
            entity.ModifyDate = DateTime.Now;
            entity.ModifyBy = 1;
            tb_RPT_PhysicalPropertiesOfementTests.InsertOnSubmit(entity);
            this.SubmitChanges();

        }

        public void ModifyPhysicalPropertiesOfementTest(tb_RPT_PhysicalPropertiesOfementTest entity)
        {
            tb_RPT_PhysicalPropertiesOfementTest instance = this.tb_RPT_PhysicalPropertiesOfementTests.SingleOrDefault(p => p.Id == entity.Id);
            instance.TestUnit = entity.TestUnit;
            instance.SamplingDate = entity.SamplingDate;
            instance.TestDate = entity.TestDate;
            instance.TestNumbers = entity.TestNumbers;
            instance.CementManufacturer = entity.CementManufacturer;
            instance.BatchNumber = entity.BatchNumber;
            instance.StrengthGrade = entity.StrengthGrade;
            instance.FSampleQuality = entity.FSampleQuality;
            instance.FResidueQuality = entity.FResidueQuality;
            instance.Ffineness = entity.Ffineness;
            instance.STANDSampleQuality = entity.STANDSampleQuality;
            instance.STANDWater = entity.STANDWater;
            instance.STANDConsistency = entity.STANDConsistency;
            instance.WaterStart = entity.WaterStart;
            instance.InitialOfArrival = entity.InitialOfArrival;
            instance.FinalOfArrival = entity.FinalOfArrival;
            instance.InitialSetting = entity.InitialSetting;
            instance.FinalSetting = entity.FinalSetting;
            instance.BoilBeforeA1 = entity.BoilBeforeA1;
            instance.BoilAfterC1 = entity.BoilAfterC1;
            instance.CA1 = entity.CA1;
            instance.BoilBeforeA2 = entity.BoilBeforeA2;
            instance.BoilAfterC2 = entity.BoilAfterC2;
            instance.CA2 = entity.CA2;
            instance.Average = entity.Average;
            instance.FlexuralStrength1 = entity.FlexuralStrength1;
            instance.FlexuralStrength2 = entity.FlexuralStrength2;
            instance.FlexuralStrength3 = entity.FlexuralStrength3;
            instance.TestAverage = entity.TestAverage;
            instance.FailureLoad1 = entity.FailureLoad1;
            instance.FailureLoad2 = entity.FailureLoad2;
            instance.FailureLoad3 = entity.FailureLoad3;
            instance.FailureLoad4 = entity.FailureLoad4;
            instance.FailureLoad5 = entity.FailureLoad5;
            instance.FailureLoad6 = entity.FailureLoad6;
            instance.Compressive1 = entity.Compressive1;
            instance.Compressive2 = entity.Compressive2;
            instance.Compressive3 = entity.Compressive3;
            instance.Compressive4 = entity.Compressive4;
            instance.Compressive5 = entity.Compressive5;
            instance.Compressive6 = entity.Compressive6;
            instance.AverageCompressive = entity.AverageCompressive;
            instance.Test3DFailureLoad1 = entity.Test3DFailureLoad1;
            instance.Test3DFailureLoad2 = entity.Test3DFailureLoad2;
            instance.Test3DFailureLoad3 = entity.Test3DFailureLoad3;
            instance.Test28DFailureLoad1 = entity.Test28DFailureLoad1;
            instance.Test28DFailureLoad2 = entity.Test28DFailureLoad2;
            instance.Test28DFailureLoad3 = entity.Test28DFailureLoad3;
            instance.Test3DCompressive1 = entity.Test3DCompressive1;
            instance.Test3DCompressive2 = entity.Test3DCompressive2;
            instance.Test3DCompressive3 = entity.Test3DCompressive3;
            instance.Test28DCompressive1 = entity.Test28DCompressive1;
            instance.Test28DCompressive2 = entity.Test28DCompressive2;
            instance.Test28DCompressive3 = entity.Test28DCompressive3;

            instance.FailureLoadAverage = entity.FailureLoadAverage;
            instance.CompressiveAverage = entity.CompressiveAverage;
            instance._3DFailureLoad1 = entity._3DFailureLoad1;
            instance._3DFailureLoad3 = entity._3DFailureLoad3;
            instance._3DFailureLoad4 = entity._3DFailureLoad4;
            instance._3DFailureLoad5 = entity._3DFailureLoad5; 
            instance._3DFailureLoad6 = entity._3DFailureLoad6;
            instance._3DCompressive1 = entity._3DCompressive1;
            instance._3DCompressive2 = entity._3DCompressive2;
            instance._3DCompressive3 = entity._3DCompressive3;
            instance._3DCompressive4 = entity._3DCompressive4;
            instance._3DCompressive5 = entity._3DCompressive5;
            instance._3DCompressive6 = entity._3DCompressive6;
            instance.TestDate3D = entity.TestDate3D;
            instance._3d = entity._3d;
            instance._3DAverage = entity._3DAverage;
            instance.TestDate28D = entity.TestDate28D;
            instance._28d = entity._28d;
            instance._28DFailureLoad1 = entity._28DFailureLoad1;
            instance._28DFailureLoad2 = entity._28DFailureLoad2;
            instance._28DFailureLoad3 = entity._28DFailureLoad3;
            instance._28DFailureLoad4 = entity._28DFailureLoad4;
            instance._28DFailureLoad5 = entity._28DFailureLoad5;
            instance._28DFailureLoad6 = entity._28DFailureLoad6;
            instance._28DCompressive1 = entity._28DCompressive1;
            instance._28DCompressive2 = entity._28DCompressive2;
            instance._28DCompressive3 = entity._28DCompressive3;
            instance._28DCompressive4 = entity._28DCompressive4;
            instance._28DCompressive5 = entity._28DCompressive5;
            instance._28DCompressive6 = entity._28DCompressive6;
            instance._28DAverage = entity._28DAverage;
            instance.Result = entity.Result;
            instance.Test = entity.Test;
            instance.Calculation = entity.Calculation;
            instance.Approval = entity.Approval; 

            instance.IsDelete = entity.IsDelete;
            instance.ModifyBy = 1; //Need to get current user
            instance.ModifyDate = DateTime.Now;

            this.SubmitChanges();
        }

        public void DeletePhysicalPropertiesOfementTest(tb_RPT_PhysicalPropertiesOfementTest entity)
        {
            tb_RPT_PhysicalPropertiesOfementTest deleteEntity = tb_RPT_PhysicalPropertiesOfementTests.SingleOrDefault(p => p.Id == entity.Id);
            tb_RPT_PhysicalPropertiesOfementTests.DeleteOnSubmit(deleteEntity);

            this.SubmitChanges();
        }

        #endregion

    }

}
